<template>
  <div class="addr">
    <!-- 头部导航 -->
    <top-nav title="收货地址" tn-name=""></top-nav>
    <van-address-list
    v-model="chosenAddressId"
    :list="list"
    default-tag-text="默认"
    @add="onAdd"
    @edit="onEdit" />
    <van-button type="primary">主要按钮</van-button>
  </div>
</template>

<script>
  import TopNav from '@/components/TopNav.vue';

  export default {
    data() {
      return {
        chosenAddressId: '1',
        list: [{
            id: '1',
            name: '张三',
            tel: '13000000000',
            address: '浙江省杭州市西湖区文三路 138 号东方通信大厦 7 楼 501 室',
            isDefault: true,
          },
          {
            id: '2',
            name: '李四',
            tel: '1310000000',
            address: '浙江省杭州市拱墅区莫干山路 50 号',
          },
        ],
      };
    },
    components: {
      TopNav
    },
    created() {
        this.axios.get("/rlg/address/selectall").then((response) => {
          if (response.data.code == 200) {
            //遍历返回数据，创建地址列表
            console.log(response)
            var records = response.data.data;
            for (var i = 0; i < records.length; i++) {

              Things[i]
            }
          } else {
            Toast.fail(response.data.msg);
          }
        })
    },
    methods: {
      onAdd() {
        this.$toast('新增地址');
      },
      onEdit(item, index) {
        this.$toast('编辑地址:' + index);
      },
    },
  };
</script>

<style>
  .addr{
    height: 600px;
    position: relative;
  }
  .van-address-list__bottom{
    position: static !important;
  }
</style>
